package www.openteam.com.presenter.business;

import java.util.HashMap;

import www.openteam.com.base.BasePresenter;
import www.openteam.com.bean.ApprovalStatu;
import www.openteam.com.contract.business.EditCustomOrderInfoContract;
import www.openteam.com.model.business.NewBuildCustomOrderInfoModel;
import www.openteam.com.mvp.IModel;
import www.openteam.com.ui.business.BuildCustomOrderMainFragment;

/**
 * Created by kylin on 2016/12/8.
 */

public class NewBuildCustomOrderInfoPresenter extends BasePresenter<BuildCustomOrderMainFragment>
        implements EditCustomOrderInfoContract.EditCustomOrderInfoPresenter {


    public void insertCustomOrderMainInfo(
            String custid, String businessno,
            String userid,
            String moneytype, String paytime
            , String sendtype, String custorderid
            , String alreadlypay, String inputdate
            , String inputer, String orderamount
            , String remark, String orderdate
            , String sendaddress, String istax
            , String taxrate, String invtype
            , String stype
    ) {
        if (!getIView().checkMainNull()) {
            ((NewBuildCustomOrderInfoModel) getiModelMap().get("editCustom"))
                    .insertCustomOrderMainInfo(custid, businessno, userid, moneytype, paytime,
                            sendtype, custorderid, alreadlypay, inputdate, inputer, orderamount,
                            remark, orderdate, sendaddress, istax, taxrate, invtype, stype
                            , new NewBuildCustomOrderInfoModel.InsertCustomOrderInfoOnListener() {
                                @Override
                                public void insertCOISuccess(ApprovalStatu approvalStatu) {
                                    getIView().insertCOIData(approvalStatu);
                                }

                                @Override
                                public void insertdCOIFail(Throwable throwable) {
                                    getIView().hideCOIData(throwable);
                                }
                            });
        }
    }


    @Override
    public void insertCustomOrderItemInfo(int id, String prodno,
                                          String wraptype, String paperinf, String senddate,
                                          String technicsinf, String printcolor, String paynumb,
                                          String othernumb, String price) {
        if (!getIView().checkItemNull()) {
            ((NewBuildCustomOrderInfoModel) getiModelMap().get("editCustom"))
                    .insertCustomOrderItemInfo(id, prodno, wraptype, paperinf, senddate, technicsinf, printcolor,
                            paynumb, othernumb, price, new NewBuildCustomOrderInfoModel.InsertCustomOrderItemInfoOnListener() {
                                @Override
                                public void insertCOIISuccess(ApprovalStatu approvalStatu) {
                                    getIView().insertCOIIData(approvalStatu);
                                }

                                @Override
                                public void insertCOIIFail(Throwable throwable) {
                                    getIView().hideCOIIData(throwable);
                                }
                            });
        }
    }
//
//
//    @Override
//    public void updateCustomOrderMainInfo(int id, String rdsno, String custid, String userid, String moneytype, String paytime, String sendtype, String custorderid, String alreadlypay, String inputdate, String inputer, String orderamount, String remark, String orderdate, String sendaddress, String istax, String taxrate, String invtype, String stype) {
//        ((NewBuildCustomOrderInfoModel) getiModelMap().get("editCustom"))
//
//    }

    @Override
    public HashMap<String, IModel> getiModelMap() {
        return loadModelMap(new NewBuildCustomOrderInfoModel());
    }

    @Override
    public HashMap<String, IModel> loadModelMap(IModel... models) {
        HashMap<String, IModel> hashMap = new HashMap<>();
        hashMap.put("editCustom", models[0]);
        return hashMap;
    }
}
